




/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MaDepartmentManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MaDepartmentManagerBase : ManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		
		public MaDepartmentManagerBase()
		{
			// Nothing for now.
		}
		
		public override string TableName()
        {
            return "MaDepartment";
        }
		
		public MaDepartmentEntity Insert(MaDepartmentEntity _MaDepartmentEntity)
		{
			return Insert(_MaDepartmentEntity, "");
		}
		
		public MaDepartmentEntity Insert(MaDepartmentEntity _MaDepartmentEntity, string controlId)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(_MaDepartmentEntity, true);
				MaDepartmentFields field = new MaDepartmentFields();
                LogEntity(_MaDepartmentEntity, field, AcInsert, controlId);
			}
			return _MaDepartmentEntity;
		}

		
		public MaDepartmentEntity Insert(Guid Id, string DepartCode, string DepartName, int Priority, string Description, string CreatedBy, DateTime CreatedDate, string UpdatedBy, DateTime UpdatedDate, bool IsDeleted)
		{
			MaDepartmentEntity _MaDepartmentEntity = new MaDepartmentEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MaDepartmentEntity.Id = Id;
				_MaDepartmentEntity.DepartCode = DepartCode;
				_MaDepartmentEntity.DepartName = DepartName;
				_MaDepartmentEntity.Priority = Priority;
				_MaDepartmentEntity.Description = Description;
				_MaDepartmentEntity.CreatedBy = CreatedBy;
				_MaDepartmentEntity.CreatedDate = CreatedDate;
				_MaDepartmentEntity.UpdatedBy = UpdatedBy;
				_MaDepartmentEntity.UpdatedDate = UpdatedDate;
				_MaDepartmentEntity.IsDeleted = IsDeleted;
				MaDepartmentFields field = new MaDepartmentFields();
                LogEntity(_MaDepartmentEntity, field, AcInsert);
				adapter.SaveEntity(_MaDepartmentEntity, true);
			}
			return _MaDepartmentEntity;
		}

		public MaDepartmentEntity Insert(string DepartCode, string DepartName, int Priority, string Description, string CreatedBy, DateTime CreatedDate, string UpdatedBy, DateTime UpdatedDate, bool IsDeleted)
		{
			MaDepartmentEntity _MaDepartmentEntity = new MaDepartmentEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MaDepartmentEntity.DepartCode = DepartCode;
				_MaDepartmentEntity.DepartName = DepartName;
				_MaDepartmentEntity.Priority = Priority;
				_MaDepartmentEntity.Description = Description;
				_MaDepartmentEntity.CreatedBy = CreatedBy;
				_MaDepartmentEntity.CreatedDate = CreatedDate;
				_MaDepartmentEntity.UpdatedBy = UpdatedBy;
				_MaDepartmentEntity.UpdatedDate = UpdatedDate;
				_MaDepartmentEntity.IsDeleted = IsDeleted;
				adapter.SaveEntity(_MaDepartmentEntity, true);
				MaDepartmentFields field = new MaDepartmentFields();
                LogEntity(_MaDepartmentEntity, field, AcInsert);
			}
			return _MaDepartmentEntity;
		}
		
		public bool Update(MaDepartmentEntity _MaDepartmentEntity)
        {
            return Update(_MaDepartmentEntity, "");
        }

		public bool Update(MaDepartmentEntity _MaDepartmentEntity, string controlId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(MaDepartmentFields.Id == _MaDepartmentEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_MaDepartmentEntity, filter);
				toReturn = true;
				
				MaDepartmentFields field = new MaDepartmentFields();
                LogEntity(_MaDepartmentEntity, field, AcUpdate, controlId);
			}
			return toReturn;
		}
		
		public bool Update(MaDepartmentEntity _MaDepartmentEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_MaDepartmentEntity, filter);
				toReturn = true;
				
				MaDepartmentFields field = new MaDepartmentFields();
                LogEntity(_MaDepartmentEntity, field, AcUpdate);
			}
			return toReturn;
		}

		public bool Update(Guid Id, string DepartCode, string DepartName, int Priority, string Description, string CreatedBy, DateTime CreatedDate, string UpdatedBy, DateTime UpdatedDate, bool IsDeleted)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaDepartmentEntity _MaDepartmentEntity = new MaDepartmentEntity(Id);
				if (adapter.FetchEntity(_MaDepartmentEntity))
				{
				
					_MaDepartmentEntity.DepartCode = DepartCode;
					_MaDepartmentEntity.DepartName = DepartName;
					_MaDepartmentEntity.Priority = Priority;
					_MaDepartmentEntity.Description = Description;
					_MaDepartmentEntity.CreatedBy = CreatedBy;
					_MaDepartmentEntity.CreatedDate = CreatedDate;
					_MaDepartmentEntity.UpdatedBy = UpdatedBy;
					_MaDepartmentEntity.UpdatedDate = UpdatedDate;
					_MaDepartmentEntity.IsDeleted = IsDeleted;
					adapter.SaveEntity(_MaDepartmentEntity, true);
					toReturn = true;
					
					MaDepartmentFields field = new MaDepartmentFields();
					LogEntity(_MaDepartmentEntity, field, AcUpdate);
				}
			}
			return toReturn;
		}

		public bool Delete(Guid Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaDepartmentEntity _MaDepartmentEntity = new MaDepartmentEntity(Id);
				if (adapter.FetchEntity(_MaDepartmentEntity))
				{
					adapter.DeleteEntity(_MaDepartmentEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("MaDepartmentEntity", null);
			}
		}
		
		
		public int DeleteById(Guid Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDepartCode(string DepartCode)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartCode == DepartCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDepartName(string DepartName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartName == DepartName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByPriority(int Priority)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Priority == Priority);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByDescription(string Description)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCreatedBy(string CreatedBy)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByCreatedDate(DateTime CreatedDate)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByUpdatedBy(string UpdatedBy)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByUpdatedDate(DateTime UpdatedDate)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsDeleted(bool IsDeleted)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MaDepartmentEntity", filter);
			}
			return toReturn;
		}
		

		
		public MaDepartmentEntity SelectOne(Guid Id)
		{
			MaDepartmentEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MaDepartmentEntity _MaDepartmentEntity = new MaDepartmentEntity(Id);
				if (adapter.FetchEntity(_MaDepartmentEntity))
				{
					toReturn = _MaDepartmentEntity;
				}
			}
			return toReturn;
		}

		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectAllLST()
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, null, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectAllLST_Paged(int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, null, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByIdLST(Guid Id)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByIdLST_Paged(Guid Id, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(Guid Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT_Paged(Guid Id, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByDepartCodeLST(string DepartCode)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartCode == DepartCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByDepartCodeLST_Paged(string DepartCode, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartCode == DepartCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDepartCodeRDT(string DepartCode)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartCode == DepartCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByDepartCodeRDT_Paged(string DepartCode, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartCode == DepartCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByDepartNameLST(string DepartName)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartName == DepartName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByDepartNameLST_Paged(string DepartName, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartName == DepartName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDepartNameRDT(string DepartName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartName == DepartName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByDepartNameRDT_Paged(string DepartName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.DepartName == DepartName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByPriorityLST(int Priority)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Priority == Priority);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByPriorityLST_Paged(int Priority, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Priority == Priority);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByPriorityRDT(int Priority)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Priority == Priority);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByPriorityRDT_Paged(int Priority, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Priority == Priority);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByDescriptionLST(string Description)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByDescriptionLST_Paged(string Description, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByDescriptionRDT(string Description)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByDescriptionRDT_Paged(string Description, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.Description == Description);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByCreatedByLST(string CreatedBy)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByCreatedByLST_Paged(string CreatedBy, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedByRDT(string CreatedBy)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedByRDT_Paged(string CreatedBy, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedBy == CreatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByCreatedDateLST(DateTime CreatedDate)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByCreatedDateLST_Paged(DateTime CreatedDate, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedDateRDT(DateTime CreatedDate)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByCreatedDateRDT_Paged(DateTime CreatedDate, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.CreatedDate == CreatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByUpdatedByLST(string UpdatedBy)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByUpdatedByLST_Paged(string UpdatedBy, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedByRDT(string UpdatedBy)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedByRDT_Paged(string UpdatedBy, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedBy == UpdatedBy);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByUpdatedDateLST(DateTime UpdatedDate)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByUpdatedDateLST_Paged(DateTime UpdatedDate, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedDateRDT(DateTime UpdatedDate)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByUpdatedDateRDT_Paged(DateTime UpdatedDate, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.UpdatedDate == UpdatedDate);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByIsDeletedLST(bool IsDeleted)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null);
			}
			return _MaDepartmentCollection;
		}
		
		// Return EntityCollection<MaDepartmentEntity>
		public EntityCollection<MaDepartmentEntity> SelectByIsDeletedLST_Paged(bool IsDeleted, int PageNumber, int PageSize)
		{
			EntityCollection<MaDepartmentEntity> _MaDepartmentCollection = new EntityCollection<MaDepartmentEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MaDepartmentCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MaDepartmentCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsDeletedRDT(bool IsDeleted)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsDeletedRDT_Paged(bool IsDeleted, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MaDepartmentCollection = new EntityCollection(new MaDepartmentEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MaDepartmentFields.IsDeleted == IsDeleted);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MaDepartmentCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		

	}
}
